package org.spolo.android.app.main;

import org.spolo.android.app.adapter.UiListener;
import org.spolo.android.app.topic.AppTopicManager;
import org.spolo.android.support.nodetree.StageView;

import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.GestureDetector;
import android.view.MotionEvent;

public class BaseSceneTree extends Activity {
	private GestureDetector detector;
	/**
	 * 屏幕的宽度
	 */
	public static int width;
	/**
	 * 屏幕的高度
	 */
	public static int height;
	private StageView sv;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		sv = new StageView(this);
		setContentView(sv);
		// 获取屏幕的宽高
		DisplayMetrics dm = new DisplayMetrics();
		dm = this.getApplicationContext().getResources().getDisplayMetrics();
		width = dm.widthPixels;
		height = dm.heightPixels;
		AppTopicManager.instance().topicChanged(AppTopicManager.SHOW360);
		detector = new GestureDetector(new UiListener());
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		return detector.onTouchEvent(event);
	}

	@Override
	public void onBackPressed() {
		// 暂时使用强制退出的办法来消除view的残影
		android.os.Process.killProcess(android.os.Process.myPid());
		super.onBackPressed();
	}
}